package cn.village.service.impl;
import cn.village.dao.ConstructionContractMapper;
import cn.village.entity.ConstructionContract;
import cn.village.service.ConstructionContractService;
import org.springframework.stereotype.Service;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.ArrayList;
import java.util.HashMap;

@Service
public class ConstructionContractServiceImpl implements ConstructionContractService {

    @Resource
    private ConstructionContractMapper constructionContractMapper;

    public ConstructionContract getConstructionContractById(String id)throws Exception{
        return constructionContractMapper.getConstructionContractById(id);
    }

    public List<ConstructionContract>	getConstructionContractListByMap(Map<String,Object> param)throws Exception{
        return constructionContractMapper.getConstructionContractListByMap(param);
    }

    public Integer getConstructionContractCountByMap(Map<String,Object> param)throws Exception{
        return constructionContractMapper.getConstructionContractCountByMap(param);
    }

    public Integer qdtxAddConstructionContract(ConstructionContract constructionContract)throws Exception{
            //constructionContract.setCreatedTime(new Date());
            return constructionContractMapper.insertConstructionContract(constructionContract);
    }

    public Integer qdtxModifyConstructionContract(ConstructionContract constructionContract)throws Exception{
        //constructionContract.setUpdatedTime(new Date());
        return constructionContractMapper.updateConstructionContract(constructionContract);
    }

    public Integer qdtxDeleteConstructionContractById(String id)throws Exception{
        return constructionContractMapper.deleteConstructionContractById(id);
    }

    public Integer qdtxBatchDeleteConstructionContract(String ids)throws Exception{
        Map<String,List<String>> param=new HashMap<String,List<String>>();
        String[] paramArrays=ids.split(",");
        List<String> idList=new ArrayList<String>();
            for (String temp:paramArrays){
                idList.add(temp);
            }
        param.put("ids",idList);
        return constructionContractMapper.batchDeleteConstructionContract(param);
    }


}
